package com.api.service.impl;

import cn.hutool.core.util.StrUtil;
import com.api.common.page.PageData;
import com.api.common.service.impl.BaseServiceImpl;
import com.api.entity.Feedback;
import com.api.entity.Item;
import com.api.entity.dto.FeedbackDTO;
import com.api.entity.dto.ItemDTO;
import com.api.mapper.FeedbackMapper;
import com.api.service.IFeedbackService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 反馈表 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-08-14
 */
@Service
public class FeedbackServiceImpl extends BaseServiceImpl<FeedbackMapper, Feedback> implements IFeedbackService {

    @Override
    public PageData<FeedbackDTO> page(Map<String, Object> params) {
        IPage<Feedback> page = baseDao.selectPage(getPage(params,  false),
                getWrapper(params)
        );
        return getPageData(page, FeedbackDTO.class);
    }
    private QueryWrapper<Feedback> getWrapper(Map<String, Object> params) {
        String isView = (String) params.get("isView");

        QueryWrapper<Feedback> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(isView), "is_view", isView);
        return wrapper;
    }

}
